﻿<%@ Page Title="Quản lý thông tin đặt xe" MasterPageFile="~/Admin/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="QLThongTinDatXe.aspx.cs" Inherits="Transport.Admin.QLThongTinDatXe" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p>
    <b>ID:</b>
    <asp:TextBox ID="txt_ID" runat="server" />
    <b>Tên đăng nhập:</b>
    <asp:TextBox ID="txt_Username" runat="server" />
    <asp:Button ID="btn_Search" runat="server" Text="Tìm" />
</p>
<p>
    <b>Dịch vụ:</b>
    <asp:DropDownList ID="ddl_DV" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
        DataValueField="id_dich_vu" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_DV" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="dich_vu" EntityTypeFilter="dich_vu">
    </asp:EntityDataSource>
    <b>Tình trạng:</b>
    <asp:DropDownList ID="ddl_Status" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_Status" DataTextField="ten_tinh_trang" 
        DataValueField="ma_tinh_trang_dat_xe" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>  
    <asp:EntityDataSource ID="EntityDataSource_Status" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="tinh_trang_dat_xe" EntityTypeFilter="tinh_trang_dat_xe">
    </asp:EntityDataSource>
    <b>Phương thức lái:</b>
    <asp:DropDownList ID="ddl_PTL" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_PTL" DataTextField="ten_phuong_thuc" 
        DataValueField="ma_phuong_thuc" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_PTL" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="phuong_thuc_lai" EntityTypeFilter="phuong_thuc_lai">
    </asp:EntityDataSource>
</p>
<p>
    <b>Lộ trình:</b>
    <asp:DropDownList ID="ddl_LT" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_LT" DataTextField="ten_lo_trinh" 
        DataValueField="ma_lo_trinh" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_LT" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="lo_trinh" EntityTypeFilter="lo_trinh">
    </asp:EntityDataSource>
    <b>Miền:</b>
    <asp:DropDownList ID="ddl_Mien" runat="server" AutoPostBack="True" 
        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
        DataValueField="ma_mien" AppendDataBoundItems="true">
        <asp:ListItem text="Select All" value="-1" />
    </asp:DropDownList>
    <asp:EntityDataSource ID="EntityDataSource_Mien" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableFlattening="False" 
        EntitySetName="miens">
    </asp:EntityDataSource>
</p>
<div style="zoom: 1; overflow: auto;">
    <asp:GridView ID="GridView_Resrv" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="id" CellSpacing="4"
        DataSourceID="EntityDataSource_Rersv" ForeColor="#333333" GridLines="None">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="Chọn">
                <ItemTemplate>
                    <asp:CheckBox ID="cb_Select" runat="server">
                    </asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" 
                SortExpression="id" />
            <asp:BoundField DataField="ngay_dat" HeaderText="Ngày đặt" ReadOnly="True"  DataFormatString="{0:d}" ApplyFormatInEditMode="true"
                SortExpression="ngay_dat" />
            <asp:BoundField DataField="ten_dang_nhap" HeaderText="Tên ĐN" 
                SortExpression="ten_dang_nhap" />
            <asp:TemplateField HeaderText="Dịch vụ">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uDV" runat="server" 
                        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
                        DataValueField="id_dich_vu"  SelectedValue='<%# Bind("ma_dich_vu") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uDV1" runat="server" 
                        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
                        DataValueField="id_dich_vu"  SelectedValue='<%# Bind("ma_dich_vu") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tình trạng">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uStatus" runat="server" 
                        DataSourceID="EntityDataSource_Status" DataTextField="ten_tinh_trang" 
                        DataValueField="ma_tinh_trang_dat_xe" SelectedValue='<%# Bind("ma_tinh_trang_dat_xe") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uStatus1" runat="server" 
                        DataSourceID="EntityDataSource_Status" DataTextField="ten_tinh_trang" 
                        DataValueField="ma_tinh_trang_dat_xe" SelectedValue='<%# Bind("ma_tinh_trang_dat_xe") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="PT lái">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uPTL" runat="server" 
                        DataSourceID="EntityDataSource_PTL" DataTextField="ten_phuong_thuc" 
                        DataValueField="ma_phuong_thuc" SelectedValue='<%# Bind("phuong_thuc_lai") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uPTL1" runat="server" 
                        DataSourceID="EntityDataSource_PTL" DataTextField="ten_phuong_thuc" 
                        DataValueField="ma_phuong_thuc" SelectedValue='<%# Bind("phuong_thuc_lai") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="so_cho" HeaderText="Số chỗ" 
                SortExpression="so_cho" />
            <asp:BoundField DataField="so_luong_xe" HeaderText="SL xe" 
                SortExpression="so_luong_xe" />
            <asp:BoundField DataField="tu_ngay" HeaderText="Từ ngày"  DataFormatString="{0:d}" ApplyFormatInEditMode="true"
                SortExpression="tu_ngay" />
            <asp:BoundField DataField="den_ngay" HeaderText="Đến ngày"  DataFormatString="{0:d}" ApplyFormatInEditMode="true"
                SortExpression="den_ngay" />
            <asp:BoundField DataField="gio_don" HeaderText="Giờ đón" 
                SortExpression="gio_don" />
            <asp:BoundField DataField="dia_diem_don" HeaderText="Địa điểm đón" 
                SortExpression="dia_diem_don" />
            <asp:BoundField DataField="ghi_chu" HeaderText="Ghi chú" 
                SortExpression="ghi_chu" />
            <asp:TemplateField HeaderText="Lộ trình">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uLT" runat="server" 
                        DataSourceID="EntityDataSource_LT" DataTextField="ten_lo_trinh" 
                        DataValueField="ma_lo_trinh" SelectedValue='<%# Bind("ma_lo_trinh") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uLT1" runat="server" 
                        DataSourceID="EntityDataSource_LT" DataTextField="ten_lo_trinh" 
                        DataValueField="ma_lo_trinh" SelectedValue='<%# Bind("ma_lo_trinh") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Miền">
                <ItemTemplate>
                    <asp:DropDownList ID="ddl_uMien" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddl_uMien1" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ti_le_giam_gia" HeaderText="TL giảm giá" 
                SortExpression="ti_le_giam_gia" />
            <asp:BoundField DataField="chi_phi_du_kien" HeaderText="CP dự kiến" 
                SortExpression="chi_phi_du_kien" />
            <asp:BoundField DataField="tien_da_thanh_toan" HeaderText="Tiền đã TT" 
                SortExpression="tien_da_thanh_toan" />
        </Columns>
        <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <SortedAscendingCellStyle BackColor="#FDF5AC" />
        <SortedAscendingHeaderStyle BackColor="#4D0000" />
        <SortedDescendingCellStyle BackColor="#FCF6C0" />
        <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    <asp:EntityDataSource ID="EntityDataSource_Rersv" runat="server" 
        ConnectionString="name=transportEntities" 
        DefaultContainerName="transportEntities" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
        EntitySetName="chi_tiet_dat_xe" EntityTypeFilter="chi_tiet_dat_xe"
        Where="it.ma_dich_vu = CASE WHEN @DV = '-1' THEN  it.ma_dich_vu ELSE @DV END
        AND it.ma_tinh_trang_dat_xe = CASE WHEN @Status = '-1' THEN  it.ma_tinh_trang_dat_xe ELSE @Status END
        AND it.phuong_thuc_lai = CASE WHEN @PTL = '-1' THEN  it.phuong_thuc_lai ELSE @PTL END
        AND it.ma_lo_trinh = CASE WHEN @LT = '-1' THEN  it.ma_lo_trinh ELSE @LT END
        AND it.ma_mien = CASE WHEN @Mien = '-1' THEN  it.ma_mien ELSE @Mien END" >
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_DV" Type="String"
                Name="DV" PropertyName="SelectedValue"/>
        </WhereParameters>
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_Status" Type="String"
                Name="Status" PropertyName="SelectedValue"/>
        </WhereParameters>
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_PTL" Type="String"
                Name="PTL" PropertyName="SelectedValue"/>
        </WhereParameters>
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_LT" Type="String"
                Name="LT" PropertyName="SelectedValue"/>
        </WhereParameters>
        <WhereParameters>
            <asp:ControlParameter ControlID="ddl_Mien" Type="String"
                Name="Mien" PropertyName="SelectedValue"/>
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_Rersv">
        <asp:SearchExpression DataFields="id" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_ID" />
        </asp:SearchExpression>
        <asp:SearchExpression DataFields="ten_dang_nhap" SearchType="Contains">
            <asp:ControlParameter ControlID="txt_Username" />
        </asp:SearchExpression>
        <asp:OrderByExpression DataField="ngay_dat" Direction="Ascending" />
    </asp:QueryExtender>
</div>
<p>
    <b>Tính toán và cập nhật tự động chi phí dự kiến:</b>
    <asp:Button ID="btn_Calculate" runat="server" Text="Tính" 
        onclick="btn_Calculate_Click" />
</p>
<p>
    <b>Duyệt đặt xe:</b>
    <asp:Button ID="btn_Confirm" runat="server" Text="Duyệt" 
        onclick="btn_Confirm_Click" />
</p>
<p>
    <b>Hủy đặt xe:</b>
    <asp:Button ID="btn_Cancel" runat="server" Text="Hủy" 
        onclick="btn_Cancel_Click" />
</p>
<p>
    <asp:Button ID="btn_CreateID" runat="server" Text="Tạo ID đặt xe" 
        onclick="btn_CreateID_Click" />
    <asp:TextBox ID="txt_ResvrID" runat="server"></asp:TextBox>
</p>
<p>
    <asp:DetailsView ID="DetailsView_Rersv" runat="server" Height="50px" 
        Width="125px" AutoGenerateRows="False" BackColor="White" BorderColor="#CCCCCC" 
        BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="id" 
        DataSourceID="EntityDataSource_Rersv" DefaultMode="Insert" 
        ForeColor="Black" FieldHeaderStyle-Wrap="false"
        GridLines="Horizontal" oniteminserted="DetailsView_Rersv_ItemInserted">
        <EditRowStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
        <Fields>
            <asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" 
                SortExpression="id" />
            <asp:BoundField DataField="ngay_dat" HeaderText="Ngày đặt"  DataFormatString="{0:d}"
                SortExpression="ngay_dat" />
            <asp:BoundField DataField="ten_dang_nhap" HeaderText="Tên ĐN" 
                SortExpression="ten_dang_nhap" />
            <asp:TemplateField HeaderText="Dịch vụ">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iDV" runat="server"
                        DataSourceID="EntityDataSource_DV" DataTextField="ten_dich_vu" 
                        DataValueField="id_dich_vu"  SelectedValue='<%# Bind("ma_dich_vu") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tình trạng">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iStatus" runat="server" 
                        DataSourceID="EntityDataSource_Status" DataTextField="ten_tinh_trang" 
                        DataValueField="ma_tinh_trang_dat_xe" SelectedValue='<%# Bind("ma_tinh_trang_dat_xe") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="PT lái">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iPTL" runat="server" 
                        DataSourceID="EntityDataSource_PTL" DataTextField="ten_phuong_thuc" 
                        DataValueField="ma_phuong_thuc" SelectedValue='<%# Bind("phuong_thuc_lai") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="so_cho" HeaderText="Số chỗ" 
                SortExpression="so_cho" />
            <asp:BoundField DataField="so_luong_xe" HeaderText="SL xe" 
                SortExpression="so_luong_xe" />
            <asp:BoundField DataField="tu_ngay" HeaderText="Từ ngày"  DataFormatString="{0:d}"
                SortExpression="tu_ngay" />
            <asp:BoundField DataField="den_ngay" HeaderText="Đến ngày"  DataFormatString="{0:d}"
                SortExpression="den_ngay" />
            <asp:BoundField DataField="gio_don" HeaderText="Giờ đón" 
                SortExpression="gio_don" />
            <asp:BoundField DataField="dia_diem_don" HeaderText="Địa điểm đón" 
                SortExpression="dia_diem_don" />
            <asp:BoundField DataField="ghi_chu" HeaderText="Ghi chú" 
                SortExpression="ghi_chu" />
            <asp:TemplateField HeaderText="Lộ trình">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iLT" runat="server" 
                        DataSourceID="EntityDataSource_LT" DataTextField="ten_lo_trinh" 
                        DataValueField="ma_lo_trinh" SelectedValue='<%# Bind("ma_lo_trinh") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Miền">
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddl_iMien" runat="server" 
                        DataSourceID="EntityDataSource_Mien" DataTextField="ten_mien" 
                        DataValueField="ma_mien" SelectedValue='<%# Bind("ma_mien") %>'>
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ti_le_giam_gia" HeaderText="TL giảm giá" 
                SortExpression="ti_le_giam_gia" />
            <asp:BoundField DataField="chi_phi_du_kien" HeaderText="CP dự kiến" 
                SortExpression="chi_phi_du_kien" />
            <asp:BoundField DataField="tien_da_thanh_toan" HeaderText="Tiền đã TT" 
                SortExpression="tien_da_thanh_toan" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
    </asp:DetailsView>
</p>
</asp:Content>